var api = require('../../config/api.js');
const util = require('../../utils/util.js');

const app = getApp();

Component({
  data: {},
  properties: {
    name:{
      type: String,
      value: ""
    },
    sex:{
      type: String,
      value: null
    },
    age:{
      type: String,
      value: null
    },
    status:{
      type: String,
      value: null
    },
    patientId:{
      type: String,
      value: null
    },
    userId:{
      type: Number,
      value: null
    }
  },
  methods: {
    gotoRecords(event){
      console.log('gotoRecords patientId = ' + this.properties.patientId);
      wx.navigateTo({
        url: "/pages/patient/condition-records/records?patientId=" + this.properties.patientId + '&name=' + this.properties.name
      });
    },
    gotoModify(event){
      console.log('gotoModify id = ' + this.properties.patientId);
      wx.navigateTo({
        url: "/pages/nurse/patient_treat_info/patient_treat_info?patientId=" + this.properties.patientId
      });
    },
    gotoInfo(event){
      console.log('gotoModify id = ' + this.properties.patientId);
      wx.navigateTo({
        url: "/pages/nurse/getpatientinfo/getpatientinfo?patientId=" + this.properties.patientId
      });
    },
    gotoVerify(event){
      console.log('gotoVerify id = ' + this.properties.patientId);
      wx.request({
        url: api.verifyPatient,
        data: parseInt(this.properties.patientId),
        method: 'POST',
        header: {
          'content-type': 'application/json'
        },
        success: function(res) {
          if (res.data.errno == 0) {
            this.properties.status = 'true';
            wx.showModal({
              title: '病人资料已审核',
              content: res.data.errmsg,
              showCancel: false
            });
          } else {
            wx.showModal({
              title: '错误信息',
              content: res.data.errmsg,
              showCancel: false
            });
          }
        }
      });
    },
  }
})